package com.seven;

import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import springfox.documentation.service.Contact;
/**
 * http://www.cnblogs.com/java-zhao/p/5348113.html
 * http://blog.csdn.net/catoop/article/details/50668896
 * @包名 com.seven
 * @类名: Swagger2
 * @描述: TODO(这里用一句话描述这个类的作用)
 * @作者 Xiaohong
 * @创建时间 2017年3月10日 上午12:06:56
 * @Version 1.0
 */
@Configuration
@EnableSwagger2
public class Swagger2 {
    @SuppressWarnings("unchecked")
	@Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
        		.groupName("hmetting")
                .apiInfo(apiInfo())
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.seven"))
               // .paths(PathSelectors.any())
                .paths(or(regex("/users/.*")))//只显示匹配的接口的名称
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
        		.license("张付红版权所有")
                .title("宏立城集团restfulAPI大全Demo")
                .description("社区电商app api大全")
                /*.termsOfServiceUrl("http://localhost:8080/")
                .contact(new Contact("张付红", "www.qq.com", "806970740@qq.com"))*/
                .version("1.0")
                /*.license("The Apache License, Version 2.0")
                .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")*/
                .build()
                ;
    }
}